package com.team.RunsFast_Api.controller;

import com.team.RunsFast_Api.config.SystemConfig;
import com.team.RunsFast_Api.service.intf.AddressService;
import com.team.runsfast.entity.Address;
import com.team.runsfast.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description:
 * @Author: 邢朋辉
 * @Date: 2022/09/22 13:09:50
 */
@RestController
@RequestMapping("/api/address/")
@CrossOrigin
@Api(tags = "收货地址相关操作")
public class AddressController {
    @Autowired
    private AddressService service;

    /**新增*/
    @PostMapping("save.do")
    public R save(@RequestBody Address obj, HttpServletRequest request){
        return service.save(obj,request.getHeader(SystemConfig.HEADER_TOKEN));
    }
    /**查询我的收货地址*/
    @GetMapping("my.do")
    public R my(HttpServletRequest request){
        return service.queryMy(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    /**查询*/
    @GetMapping("all.do")
    public R all(){
        return service.queryAll();
    }
}